/**
 * \file kernel/driver/fs/initramfs/initramfs.c
 * \author Davide Gessa
 * \date 12/22/2009
 */
#include "initramfs.h"
#include <driver.h>
#include <fs/fs.h>
#include <main.h>


driver_t driver_initramfs =
{
	.name = "initramfs\0",
	
	.type = DRV_TYPE_FS,
	.fs.mount = initramfs_mount,
	.fs.umount = initramfs_umount,
	.fs.readdir = initramfs_readdir,
	.fs.rmdir = NULL,
	.fs.mkdir = NULL,
	
	.fs.ifdev = 0
};


/**
 * Legge il contenuto della dir principale
 */
uint32_t initramfs_readdir(inode_t *root, uint32_t n, struct dirent *d)
{
	initramfs_node_t *node = (initramfs_node_t *) (mod_addr + (sizeof(initramfs_node_t) * n));
	
	strcpy(d->name, "\0");
	
	printf("%d - %d - %s - %d\n",node->identify, 0xABCDEF, node->name, mod_addr);
	if(node->identify == 0xABCDEF)
	{
		strcpy(d->name, node->name);
		d->inode = node->n;
		return 0;
	}
	else
		return 1;
}


/**
 * Umonta il initramfs
 */
uint32_t initramfs_umount(inode_t *root)
{
	//root->childs = NULL;

	return MOUNT_STATE_OK;
}



/**
 * Monta il initramfs
 */
uint32_t initramfs_mount(char *dev, uint32_t flags, inode_t *root)
{
	return MOUNT_STATE_OK;
}


